<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>登录</title>
<%@ include file="/pages/common/common.jsp" %>
<script type="text/javascript">	
	$(function(){
		//回车键触发登录
		$("body").keydown(function(event){
			if(event.keyCode==13)
				login();
		});
	});
	 /** 登录 */
	function login(){
		var r = $('#loginForm').form('validate');
		if(!r) {
			return false;
		}
		var url="${ctx}/user/login.usr";
		var param = "userName="+$('#userName').val();
		param += "&userPwd="+$('#userPwd').val();
		param += "&vcode="+$('#vcode').val();
		$.post(url,param,function(data){
			if(data.success){//操作成功
				location.href="${ctx}/pages/front/index.jsp";
			}else{
				$.messager.alert('提示',data.msg,'warning');	
			}
		});
	}
	function getVcode(){
		var url="${ctx}/vcode/getVcode.usr?time="+new Date().getTime();
		$("#codeImg").attr("src",url);	
	}
	function register(){
		location.href="${ctx}/pages/front/register.jsp";
	}
	
	
</script>
<link rel="stylesheet" type="text/css" href="${ctx}/css/login.css" />	
</head>
<body>
<div id=div1>
<form id="loginForm" method="post">
  <table id=login height="100%" cellspacing=0 cellpadding=0 width=800 
align=center>
    <tbody>
      <tr id=main>
        <td>
          <table cellspacing=0 cellpadding=0 width="100%" style="margin-top: 160px;">
            <tbody>
              <tr>
                <td colspan=4>&nbsp;</td>
              </tr>
              <tr height=30>
                <td width=380>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
              </tr>
              <tr height=40>
                <td rowspan=4>&nbsp;</td>
                <td>用户名：</td>
                <td>
                 <input name="userName" id="userName"  class="easyui-validatebox txt" validType="length[2,50]" style="width:150px;" required="true">
                </td>
                <td width=120>&nbsp;</td>
              </tr>
              <tr height=40>
                <td>密　码：</td>
                <td>
              <input name="userPwd" id="userPwd" type="password" style="width:150px" validType="length[2,30]" class="easyui-validatebox txt" required="true">
                </td>
                <td width=120>&nbsp;</td>
              </tr>
              <tr height=40>
                <td>验证码：</td>
                <td valign=center colspan=2>
                  <input id="vcode" size=7 name="vcode">
                  &nbsp; <img id="codeImg" src="${ctx}/vcode/getVcode.usr?time="+new Date().getTime()" border=0> <a id=linkbutton1 
            href="javascript:void(0);" onclick="getVcode();">不清楚，再来一张</a></td>
              </tr>
              <tr height=40>
              	<td align=center>
                  <input id=btnlogin type=button onclick="login();" value=" 登 录 " name=btnlogin>
                </td>
                <td align="center"><input id=btnregister type=button onclick="register();" value=" 注  册  " name=btnregister></td>
                <td width=120>&nbsp;</td>
                <td width=120>&nbsp;</td>
              </tr>
              <tr height=110>
                <td colspan=4>&nbsp;</td>
              </tr>
            </tbody>
          </table>
        </td>
      </tr>
      
    </tbody>
  </table>
  </form>
</div>
<DIV id=div2 style="DISPLAY: none"></DIV>
</body>
</html>